package com.mszlu.news.admin.controller;

import com.mszlu.news.admin.model.params.TagParam;
import com.mszlu.news.admin.service.TagService;
import com.mszlu.news.admin.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "文章标签")
@RestController
@RequestMapping("tag")
public class TagController {
    @Autowired
    private TagService tagService;

    @ApiOperation(value = "根据条件查询")
    @PostMapping("select")
    public Result selectTag(@RequestBody TagParam tagParam){
        return tagService.selectTag(tagParam);
    }

    @ApiOperation(value = "新增标签")
    @PostMapping("insert")
    public Result insertTag(@RequestBody TagParam tagParam){
        return tagService.insertTag(tagParam);
    }

    @ApiOperation(value = "更新标签")
    @PostMapping("update")
    public Result updateTag(@RequestBody TagParam tagParam){
        return tagService.updateTag(tagParam);
    }

    @ApiOperation(value = "通过id删除标签")
    @PostMapping("delete/{id}")
    public Result deleteTagById(@PathVariable("id") Long tagId){
        return tagService.deleteTagById(tagId);
    }
}
